home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _B796E26AC56C4126A36581CAA61E2781 < prev    next >
Encoding:
Text File  |  2004-01-06  |  7.3 KB  |  213 lines

  1. --------------------------------------------------
  2. --   Created By: Petar
  3. --   Description: Rear Combat Behavior
  4. --------------------------
  5. --
  6.  
  7. AIBehaviour.RearAttack = {
  8.     Name = "RearAttack",
  9.  
  10.  
  11. --    OnLeftLean  = function( self, entity, sender)
  12. --        local rnd=random(1,10);
  13. --        if (rnd > 5) then 
  14. --            AI:Signal(0,1,"LEFT_LEAN_ENTER",entity.id);
  15. --        end
  16. --    end,
  17. --    ---------------------------------------------
  18. --    OnRightLean  = function( self, entity, sender)
  19. --        local rnd=random(1,10);
  20. --        if (rnd > 5) then 
  21. --            AI:Signal(0,1,"LEFT_LEAN_ENTER",entity.id);
  22. --        end
  23. --    end,
  24. --    ---------------------------------------------
  25. --
  26. --    ---------------------------------------------
  27. --    OnLowHideSpot = function( self, entity, sender)
  28. --        entity:SelectPipe(0,"dig_in_attack");
  29. --    end,
  30. --
  31.  
  32.  
  33.     OnNoTarget = function( self, entity )
  34.         -- called when the enemy stops having an attention target
  35.     end,
  36.     ---------------------------------------------
  37.     OnPlayerSeen = function( self, entity, fDistance )
  38.         
  39.         entity:SelectPipe(0,"protect_spot",entity:GetName().."_PROTECT");
  40.  
  41.  
  42.         if (fDistance>8 and fDistance<30 and entity.cnt.numofgrenades>0) then 
  43.             local rnd = random(1,10);
  44.             if (rnd<3) then
  45.                 entity:InsertSubpipe(0,"rear_weaponAttack");
  46.             else
  47.                 entity:InsertSubpipe(0,"rear_grenadeAttack");
  48.             end
  49.         else
  50.             entity:InsertSubpipe(0,"rear_weaponAttack");
  51.         end
  52.  
  53.  
  54.     end,
  55.     ---------------------------------------------
  56.     OnEnemyMemory = function( self, entity )
  57.         if (AI:GetGroupCount(entity.id) > 1) then    
  58.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_LOST, "ENEMY_TARGET_LOST_GROUP",entity.id);    
  59.         else
  60.             AI:Signal(SIGNALID_READIBILITY, AIREADIBILITY_LOST, "ENEMY_TARGET_LOST",entity.id);    
  61.         end    
  62.     end,
  63.     ---------------------------------------------
  64.     OnInterestingSoundHeard = function( self, entity )
  65.         -- called when the enemy hears an interesting sound
  66.         entity:SelectPipe(0,"rear_scramble");
  67.     end,
  68.     ---------------------------------------------
  69.     OnThreateningSoundHeard = function( self, entity )
  70.         -- called when the enemy hears a scary sound
  71.         entity:SelectPipe(0,"rear_scramble");
  72.     end,
  73.     ---------------------------------------------
  74.     OnClipNearlyEmpty = function( self, entity )
  75.         -- called when the enemy goes into automatic reload after its clip is empty
  76.         entity:SelectPipe(0,"rear_scramble");
  77.     end,
  78.     ---------------------------------------------
  79.     OnReload = function ( self, entity, sender)
  80.         -- called when the AI has low ammo
  81.         -- entity:SelectPipe(0,"low_ammo");
  82.     end,
  83.     ---------------------------------------------
  84.     OnGroupMemberDied = function( self, entity )
  85.         -- called when a member of the group dies
  86.     end,
  87.     ---------------------------------------------
  88.     OnNoHidingPlace = function( self, entity, sender )
  89.         -- called when no hiding place can be found with the specified parameters
  90.     end,    
  91.     ---------------------------------------------
  92.     OnReceivingDamage = function ( self, entity, sender)
  93.         if (entity.DROP_GRENADE==nil) then
  94.             entity:SelectPipe(0,"rear_scramble");
  95.         else
  96.             entity:InsertSubpipe(0,"take_cover");
  97.         end
  98.         
  99.     end,
  100.     ---------------------------------------------
  101.     OnBulletRain = function ( self, entity, sender)
  102.         -- called when the enemy is damaged
  103.     end,
  104.     ---------------------------------------------
  105.     OnCoverRequested = function ( self, entity, sender)
  106.         -- called when the enemy is damaged
  107.     end,
  108.     ---------------------------------------------
  109.     OnDeath = function ( self, entity, sender)
  110.         -- called when the enemy is killed
  111.         -- call default processing
  112.         AIBehaviour.DEFAULT:OnDeath(entity,sender);
  113.  
  114.         if (entity.DROP_GRENADE) then
  115.             local gnd = Server:SpawnEntity("ProjFlashbangGrenade");
  116.             if (gnd) then
  117.                 gnd:Launch(nil,entity,entity:GetPos(),{x=0,y=0,z=0},{x=0,y=0,z=-0.001});
  118.             end
  119.         end
  120.     end,
  121.         ---------------------------------------------
  122.     OnGrenadeSeen = function( self, entity, fDistance )
  123.         -- called when the enemy sees a grenade
  124.         --System:LogToConsole("+++++++++++++++++++++++++++OnGrenadeSeen");
  125.         AI:Signal(SIGNALID_READIBILITY, 1, "GRENADE_SEEN",entity.id);
  126.         entity:InsertSubpipe(0,"grenade_run_hide");
  127.     end,
  128.     ---------------------------------------------
  129.     
  130.     
  131.     --------------------------------------------------
  132.     -- CUSTOM SIGNALS
  133.     --------------------------------------------------
  134.     EXCHANGE_AMMO = function (self, entity,sender)
  135.     --rear guard within throw range so throw
  136.  
  137.         entity:StartAnimation(0,"sgrenade",1);
  138.     end,
  139.     ---------------------------------------------
  140.     GRANADE_OUT = function (self, entity, sender)
  141.         entity.DROP_GRENADE = nil;
  142.     end,
  143.     ---------------------------------------------    
  144.     REAR_NORMALATTACK = function (self, entity, sender)
  145.  
  146.         entity:SelectPipe(0,"rear_comeout");
  147.  
  148.         entity.DROP_GRENADE = nil;
  149.     end,
  150.     ---------------------------------------------    
  151.     REAR_SELECTATTACK = function (self, entity, sender)
  152.     end,
  153.     --------------------------------------------------
  154.     ----------------- GROUP SIGNALS ------------------
  155.     --------------------------------------------------
  156.     HEADS_UP_GUYS = function (self, entity, sender)
  157.         entity.RunToTrigger = 1;
  158.     end,
  159.     ---------------------------------------------
  160.     OnGroupMemberDied = function( self, entity, sender)
  161.     end,
  162.     --------------------------------------------------
  163.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  164.     end,
  165.     --------------------------------------------------
  166.     KEEP_FORMATION = function (self, entity, sender)
  167.         -- the team leader wants everyone to keep formation
  168.     end,
  169.     ---------------------------------------------    
  170.     BREAK_FORMATION = function (self, entity, sender)
  171.         -- the team can split
  172.     end,
  173.     ---------------------------------------------    
  174.     SINGLE_GO = function (self, entity, sender)
  175.         -- the team leader has instructed this group member to approach the enemy
  176.     end,
  177.     ---------------------------------------------    
  178.     GROUP_COVER = function (self, entity, sender)
  179.         -- the team leader has instructed this group member to cover his friends
  180.     end,
  181.     ---------------------------------------------    
  182.     IN_POSITION = function (self, entity, sender)
  183.         -- some member of the group is safely in position
  184.     end,
  185.     ---------------------------------------------    
  186.     GROUP_SPLIT = function (self, entity, sender)
  187.         -- team leader instructs group to split
  188.     end,
  189.     ---------------------------------------------    
  190.     PHASE_RED_ATTACK = function (self, entity, sender)
  191.         -- team leader instructs red team to attack
  192.     end,
  193.     ---------------------------------------------    
  194.     PHASE_BLACK_ATTACK = function (self, entity, sender)
  195.         -- team leader instructs black team to attack
  196.     end,
  197.     ---------------------------------------------    
  198.     GROUP_MERGE = function (self, entity, sender)
  199.         -- team leader instructs groups to merge into a team again
  200.     end,
  201.     ---------------------------------------------    
  202.     CLOSE_IN_PHASE = function (self, entity, sender)
  203.         -- team leader instructs groups to initiate part one of assault fire maneuver
  204.     end,
  205.     ---------------------------------------------    
  206.     ASSAULT_PHASE = function (self, entity, sender)
  207.         -- team leader instructs groups to initiate part one of assault fire maneuver
  208.     end,
  209.     ---------------------------------------------    
  210.     GROUP_NEUTRALISED = function (self, entity, sender)
  211.         -- team leader instructs groups to initiate part one of assault fire maneuver
  212.     end,
  213. }